<template>
  <c-form :inline="true" :form="form"></c-form>
</template>

<script>
import Form from "@/components/Form";
import {mapActions, mapState} from "vuex";
import {userTaskForm} from "@/components/bpmn/components/bpmnPropertiesPanel/forms";
import {requestFormTmpList} from "@/api/bpmnApi";

export default {
  name: "UserTask_Form",
  components: {
    "c-form": Form
  },
  data() {
    return {
      form: userTaskForm.call(this)
    }
  },
  computed: mapState({
    formTmpList: state => state.flowDesignStore.formTmpList
  }),
  methods: {
    ...mapActions("flowDesignStore", ["getFormTmpList"]),
    // 数据初始化
    async initData() {
      const modelFormId = this.modeler.$element.parent.businessObject.formId
      let formTmpList = []
      const rst = await requestFormTmpList({
        formId: modelFormId
      });
      if (rst.code === 200) {
        formTmpList = rst.data;
      } else {
        this.$message({
          type: "warning",
          message: rst.message,
        });
      }
      this.form.items.form.options = formTmpList.map(item => ({
        value: item.id,
        label: item.attributeGroupName
      }));
    },
    // 数据回填
    dataReset() {
      this.form.models.form = this.businessObj.formKey;
    }
  },
}
</script>
